﻿using SqlSugar;
using System.Reflection;

namespace PersonnelManagement.Infrstructre
{
    public class SqlSugerDbcontext
    {
        protected readonly ISqlSugarClient db;
          public SqlSugerDbcontext(ISqlSugarClient db)
         {
            this.db = db;
          }
        public void CreateDatabase()
        {
          db.DbMaintenance.CreateDatabase();
            var rootpath = AppDomain.CurrentDomain.BaseDirectory;
            Type[] types=Assembly.LoadFrom(rootpath+ "PersonnelManagement.Domain.dll").GetTypes().Where(it=>it.FullName.Contains("PersonnelManagement.Domain.PersonnelDomain")).ToArray();

            db.CodeFirst.SetStringDefaultLength(200).InitTables(types);
        }

        public void createDataBase()
        {
            throw new NotImplementedException();
        }
    }
}
